<template>
  <MyContent
    :resData="resData"
    :config="config"
    :totalNumber="totalNumber"
    :pageSize="pageSize"
    :defineConfig="defineConfig"
    @handleResData="handleResData"
  />
</template>

<script>
import MyContent from "@/components/Content.vue";
export default {
  name: "myOreders",
  components: {
    MyContent,
  },
  mounted() {
    this.getGoodsList();
  },
  data() {
    return {
      config: [
        {
          prop: "objectId",
          label: "订单号",
        },
        {
          prop: "allPrice",
          label: "订单总价",
        },
        {
          prop: "state",
          label: "订单状态",
        },
        {
          prop: "deliveryTime",
          label: "配送时间",
        },
        {
          prop: "address",
          label: "收货地址",
        },
      ],
      resData: [],
      totalNumber: 0,
      pageSize: 6,
      defineConfig: {
        searchText: "请输入订单号",
        isShow: true,
        leftButtonText:'订单详情'
      },
    };
  },
  methods: {
    getGoodsList() {
      this.$H.get("/1.1/classes/order").then((res) => {
        res.data.results.forEach((item) => {
          const {
            confirm,
            objectId,
            phone,
            username,
            address,
            allNum,
            detail,
            orderlist,
            allPrice,
            deliveryTime,
          } = item;
          this.resData.push({
            state: confirm == 0 ? "未支付" : "已支付",
            objectId,
            phone,
            username,
            address,
            allNum,
            detail,
            orderlist,
            allPrice,
            deliveryTime,
          });
        });
        console.log("this.resData============",this.resData);
        this.totalNumber = res.data.results.length;
      });
    },
    handleResData(fid,lid) {
      this.resData.splice(fid,lid)
      console.log('handleResData',this.resData,fid,lid);
    }
  },
};
</script>

<style lang="less" scoped>
</style>